// FarmMachinery.java
package com.smartfarm.domain;

import com.smartfarm.observer.Observer;
import com.smartfarm.state.IdleState;
import com.smartfarm.state.State;
import com.smartfarm.strategy.OptimalPath;
import com.smartfarm.strategy.PathStrategy;

public abstract class FarmMachinery implements Observer {
    protected String id;
    protected State state;
    protected PathStrategy strategy;

    public FarmMachinery(String id) {
        this.id = id;
        // 初始化默认状态和策略
        this.state = new IdleState();  // 添加状态初始化
        this.strategy = new OptimalPath(); // 添加默认策略
    }

    public String getId() { return id; }

    public void setState(State state) {
        this.state = state;
    }

    public void setStrategy(PathStrategy strategy) {
        this.strategy = strategy;
    }

    public void startWork() {
        state.handleState(this);
        strategy.planPath();
    }
}
